var content = document.querySelector('.content');
var signupBtn = document.getElementById('signup');
var feedbackBtn = document.getElementById('feedback');

content.addEventListener('mouseenter', function() {
  content.style.transition = 'background-color 0.3s';
  content.style.backgroundColor = 'rgba(100,100,100,0.5)'; // 将透明度更改为 0.5，使背景色加深
});

content.addEventListener('mouseleave', function() {
  content.style.transition = 'background-color 0.3s';
  content.style.backgroundColor = 'rgba(100,100,100,0.2)'; // 将透明度恢复为 0.2，使背景色变浅
});

var data = [];

signupBtn.addEventListener('click', function() {

  $.ajax({
      url: '/management/onsiteservlet/ossPostSign',                              //url方法接口：发布签到
      method: 'POST',
      data: {
        username: "1"
      },
      success: function(response) {
        console.log(response);
        console.log(response.data);
        data = response.flag;

        if(!data){               // 没选择课程
            alert("未选择课程！");
        }
        else{                               // 发布签到
            alert("已发布签到！")
        }
      }
    });
});

feedbackBtn.addEventListener('click', function() {

      $.ajax({
             url: '/management/onsiteservlet/ossPostAdvice',                         //url方法接口：发布反馈
             method: 'POST',
             data: {
                  username: "1"
             },
             success: function(response) {
                console.log(response);
                data = response.flag;
                console.log(data);
                if(!data){                   // 未选择课程
                    alert("未选择课程！");
                }
                else{                               // 选择课程发布成功
                    alert("已发布现场反馈！");
                }
             }
      });
});

  var links = document.querySelectorAll('.sidebar ul li a');

  for (var i = 0; i < links.length; i++) {
    links[i].addEventListener('mouseenter', function() {
      this.style.transition = '0.2s';
      this.style.backgroundColor = '#679';
      this.style.borderRadius = '10px'; // 设置边缘的圆角半径为10px
    });

    links[i].addEventListener('mouseleave', function() {
      this.style.transition = '0.2s';
      this.style.backgroundColor = '';
      this.style.borderRadius = '10px'; // 鼠标移出时恢复原始边缘
    });
  }